package com.bestdreamer.formats;

public class Binary {

    public static String bytesToHexString(byte[] src){
        StringBuilder stringBuilder = new StringBuilder();
        if(src == null || src.length <= 0){
            return null;
        }
        for(int i = 0; i < src.length; i++){
            int v = src[i] & 0xFF;
            String hv = Integer.toHexString(v);
            stringBuilder.append(i+":");
            if(hv.length() < 2){
                stringBuilder.append(0);
            }
            stringBuilder.append(hv + ";");
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args){
        byte[] dd = {(byte) 01000101};
        System.out.println(bytesToHexString(dd));
    }
}
